﻿<!doctype html>
<html>
<head>
    <meta charset="UTF-8">  
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>运输管理系统</title>  
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>  
    <link rel="stylesheet" type="text/css" href="../js/jquery-easyui-1.4.4/themes/metro/easyui.css">  
    <link rel="stylesheet" type="text/css" href="../js/jquery-easyui-1.4.4/themes/mobile.css">  
    <link rel="stylesheet" type="text/css" href="../js/jquery-easyui-1.4.4/themes/icon.css">  
    <script type="text/javascript" src="../js/jquery-easyui-1.4.4/jquery.min.js"></script>  
    <script type="text/javascript" src="../js/jquery-easyui-1.4.4/jquery.easyui.min.js"></script> 
    <script type="text/javascript" src="../js/jquery-easyui-1.4.4/jquery.easyui.mobile.js"></script> 
    <script src="../../Scripts/jsbase.js" type="text/javascript"></script>
    <script src="../../Scripts/webcontrols/datasource.js" type="text/javascript"></script>
    <script src="scripts/newjs/page.js" type="text/javascript"></script>
    <script src="scripts/newjs/from.js" type="text/javascript"></script>
    <script src="scripts/newjs/grid.js" type="text/javascript"></script>
    <script src="scripts/newjs/textbox.js" type="text/javascript"></script>
    <script src="scripts/newjs/wx.js" type="text/javascript"></script>
    <script src="../../Scripts/store/store.js" type="text/javascript"></script>

        <script src="scripts/newbus/packlist.js" type="text/javascript"></script>
    <script src="scripts/newbus/transport.js" type="text/javascript"></script>
     <script type="text/javascript">
         $(document).ready(function () {
             var url = encodeURIComponent(location.href.split('#')[0]);
             var lg = store.get("wxlogin");
             if (lg == null) {
//                 var state = getArgsFromUrl("state");
//                 if (state != "8907653test")
                     //window.location = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + wxconfig.appId + '&redirect_uri=' + url + '&response_type=code&scope=SCOPE&state=8907653test#wechat_redirect';
             }
             else {
                 lg = JSON.parse(lg);
                 login(lg.name, lg.pass);
             }
             $("#login .easyui-linkbutton").bind("click", function () {
                 var name = $("#user").val();
                 var pass = $("#pass").val();
                 login(name, pass);
             });
         });
         function mainclick(c) {
             if (c == "scan") {
                 wx.scanQRCode({
                     desc: 'scanQRCode desc',
                     needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
                     scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有
                     success: function (res) {
                         var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
                         $.messager.show({ title: '消息', msg: result, showType: 'show' });
                     }
                 });
             }
             if (c == "packlist")
                 packlist();
             if (c == "transport")
                 transport();

         }
         function login(name, pass) {
             webjs.login(name, pass, function (obj) {
                 var url = encodeURIComponent(location.href.split('?')[0]);
                 var wxc = webjs.post("Way.Wx.JS_SDK", "getjsapi", "url=" + url);
                 wxconfig.appId = wxc.appId;
                 wxconfig.nonceStr = wxc.nonceStr;
                 wxconfig.signature = wxc.signature;
                 wxconfig.timestamp = wxc.timestamp;
                 wx.config(wxconfig);
                 var code = getArgsFromUrl("code");
                 var state = getArgsFromUrl("state");
                 if (code != "" && state != "") {
                     var d = new datasource();
                     d.c = "Way.Wx.Controllers.AccessToken";
                     var e = d.post("Login", "code=" + code + "&state=" + state);
                     if (e && e.error) {
                         $.messager.alert('异常', e.errormsg, 'error');
                         return;
                     }
                     else {
                         store.set("wxlogin", '{name:"' + name + '",pass:"' + pass + '"}');
                     }
                 }
                 var obj = {};
                 obj.name = name;
                 obj.pass = pass;
                 store.set("wxlogin", JSON.stringify(obj));
                 $.mobile.go("#main");
                 var title = $("#main .m-title").html()
                 $("title").html(title);
                 return;
             }, function (obj) {
                 $.messager.alert('异常', obj.errormsg, 'error');
             });
         }
         function getArgsFromUrl (sArgName) {
             var sHref = window.location.href;
             var args = sHref.split("?");
             var retval = "";
             if (args[0] == sHref) /*参数为空*/
             {
                 return retval; /*无需做任何处理*/
             }
             var str = args[1];
             args = str.split("&");
             for (var i = 0; i < args.length; i++) {
                 str = args[i];
                 var arg = str.split("=");
                 if (arg.length <= 1) continue;
                 if (arg[0] == sArgName)
                     retval = arg[1];
             }
             return retval;
         }
    </script>
</head>
<body>
    <div class="easyui-navpanel" id="login">
       <!-- <header>
            <div class="m-toolbar">
                <span class="m-title">登录系统</span>
            </div>
        </header>-->
        <div style="margin:20px auto;width:100px;height:100px;border-radius:100px;overflow:hidden">
            <img src="" style="margin:0;width:100%;height:100%;">
        </div>
        <div style="padding:0 20px">
            <div style="margin-bottom:10px">
                <input class="easyui-textbox" id="user" data-options="prompt:'用户名',iconCls:'icon-man'" style="width:100%;height:38px">
            </div>
            <div>
                <input class="easyui-textbox" id="pass" type="password" data-options="prompt:'密码',iconCls:'icon-lock'" style="width:100%;height:38px">
            </div>
            <div style="text-align:center;margin-top:30px">
                <a href="#" class="easyui-linkbutton" style="width:100%;height:40px"><span style="font-size:16px">登录</span></a>
            </div>
        </div>
    </div>
    <div class="easyui-navpanel" id="main">
        <header>
            <div class="m-toolbar">
                <div class="m-title">主页</div>
                <!--<div class="m-left">
                    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-man',plain:true"></a>
                </div>-->
                <div class="m-right">
                    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true"></a>
                </div>
            </div>
        </header>
         <footer>
            <div class="m-buttongroup m-buttongroup-justified" style="width:100%">
                <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-large-picture',size:'large',iconAlign:'top',plain:true">主页</a>
                <a href="javascript:void(0)" onclick="mainclick('packlist');" class="easyui-linkbutton" data-options="iconCls:'icon-large-clipart',size:'large',iconAlign:'top',plain:true">装车</a>
                <a href="javascript:void(0)" onclick="mainclick('transport');"class="easyui-linkbutton" data-options="iconCls:'icon-large-shapes',size:'large',iconAlign:'top',plain:true">运输</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-large-smartart',size:'large',iconAlign:'top',plain:true">签收</a>
            </div>
        </footer>
    </div>
    <div id="page" class="easyui-navpanel">
        <header>
            <div class="m-toolbar">
                <span id="page-title" class="m-title"></span>
               <!-- <div class="m-left">
                    <a href="javascript:void(0)" class="easyui-linkbutton m-back" plain="true" outline="true" style="width:50px" onclick="$.mobile.back()">返回</a>
                </div>-->
                <div class="m-right">
                    <a id="page-search" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true"></a>
                </div>
            </div>
        </header>
         <footer></footer>
        <ul id="page-datalist" class="easyui-datalist"></ul>
    </div>
     <div id="from" class="easyui-navpanel">
        <header>
            <div class="m-toolbar">
                <span id="from-title" class="m-title"></span>
               <!-- <div class="m-left">
                    <a href="javascript:void(0)" class="easyui-linkbutton m-back" plain="true" outline="true" style="width:50px" onclick="$.mobile.back()">返回</a>
                </div>-->
              <!--  <div class="m-right">
                    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true"></a>
                </div>-->
            </div>
        </header>
         <footer></footer>
    </div>
       <div id="search-dialog" class="easyui-dialog" style="padding:20px 6px;width:80%;" data-options="inline:true,closable:true,modal:true,closed:true,title:'查询'">
            <div style="margin-bottom:10px">
                <input id="search-text" class="easyui-textbox" prompt="条件" style="width:100%;height:30px">
            </div>
            <div class="dialog-button">
                <a id="search-button" href="javascript:void(0)" class="easyui-linkbutton" style="width:100%;height:35px" >查询</a>
                <a  href="javascript:void(0)" class="easyui-linkbutton" style="width:100%;height:35px" onclick="$('#search-dialog').dialog('close')" >取消</a>
            </div>
        </div>
</body>    
</html>